<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //返回数组元素索引引号方法(从前往后查)
        //indexOf(数组元素) 返回该数组元素的索引号

        //只返回第一个满足条件的索引号
        var arr = [6, 5, 4, 1, 6, 2];
        console.log(arr.indexOf(1)); //3
        console.log(arr.indexOf(10)); //-1  找不到元素 返回 -1

        // lastIndexOf(从后往前查找)
        console.log(arr.lastIndexOf(2));
    </script>
</head>

<body>

</body>

</html>